<template>
	<view class="tab">
		<scroll-view scroll-x class="bg-white nav text-center">
			<view class="cu-item" :class="item.name === tabcur?'text-green cur':''" v-for="(item,index) in list" :key="index" @tap="tabSelect(item.name)" :data-id="index">
				{{ item.name }}
			</view>
		</scroll-view>
		<view v-if="list.length > 0" class="tab-icons" @click="tabEmail">
			<uni-icons type="email" size="30" color="#666"></uni-icons>
		</view>
	</view>
</template>

<script>
	export default {
		name:"tab",	
		props: {
			list: {
				type: Array,
				default() {
					return []
				}
			},
			tabcur: {
				type: String,
				default: ''
			}
		},
		data() {
			return {
				
			};
		},
		methods: {
			tabSelect(item) {
				this.$emit('tab', {
					data:item
				})
			},
			tabEmail() {
				this.$emit('email')
			}
		}
	}
</script>

<style lang="scss">
	.tab {
		display: flex;
		width: 100%;
		border-bottom: 1px #f5f5f5 solid;
		background-color: #fff;
		box-sizing: border-box;
		
		.tab-scroll {
			flex: 1;
			overflow: hidden;
			box-sizing: border-box;
			
			.tab-scroll__box {
				display: flex;
				align-items: center;
				flex-wrap: nowrap;
				height: 45px;
				box-sizing: border-box;
				.tab-scroll__item {
					flex-shrink: 0;
					padding: 0 10px;
					color: #333;
					font-size: 14px;
					&.active {
						color: #39b54a;
					}
				}
			}
		}
		
		.tab-icons {
			position: relative;
			display: flex;
			justify-content: center;
			align-items: center;
			width: 45px;
			&::after {
				content: '';
				position: absolute;
				top: 12px;
				bottom: 12px;
				left: 0;
				width: 1px;
				background-color: #E8E8E8;
			}
		}
	}
</style>